package com.jlf.core.error;

import lombok.Getter;

/**
 * 定义错误码的接口
 *
 * @author wujr
 * 2021/1/12
 * @version 1.0
 * 变更历史
 * [wujr 2021/1/12 1.0 新增]
 */
@Getter
public class Code {
    private final int error;
    private final String message;

    public Code(int error, String message){
        this.error = error;
        this.message = message;
    }

    public static Code from(int error){
        return new Code(error, null);
    }

    public static final Integer SUCCEED = 0;
    public static final Integer UNKNOWN = -1;

    public static boolean succeed(Integer error){
        return SUCCEED.equals(error);
    }

    public boolean equals(Integer error){
        return error != null && error.equals(this.error);
    }
}
